import java.io.*;
import java.util.*;


class Read{
    StringTokenizer st = new StringTokenizer("");
    BufferedReader bf = new BufferedReader(new InputStreamReader(System.in));
    String next()throws IOException{
        while(!st.hasMoreTokens()){
            st = new StringTokenizer(bf.readLine());
        }
        return st.nextToken();
    }
    String nextLine()throws IOException{
        return bf.readLine();
    }
    int nextInt() throws  IOException{
        return Integer.parseInt(next());
    }
    long nextlong() throws IOException{
        return Long.parseLong(next());
    }
    double nextDouble() throws IOException{
        return Double.parseDouble(next());
    }
}


public class Main {

    //孩子们的游戏
    public  int LastRemainint_Solution(int n,int m){
        if (m == 0 || n == 0){
            return -1;
        }
        List<Integer> data = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            data.add(i);
        }
        int index = 0;
        while (data.size()>1){
            index = (index+m-1)%data.size();
            data.remove(index);
        }
        return data.get(0);
    }




    //腐烂的苹果
    static int[] dx = {0,0,1,-1};
    static int[] dy = {1,-1,0,0};
    public int rotApple(ArrayList<ArrayList<Integer>> grid){
        int m = grid.size();
        int n = grid.get(0).size();
        int ret = 0;
        boolean[][] vis = new boolean[m][n];
        Queue<int[]> q =new LinkedList<>();
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (grid.get(i).get(j) == 2){
                    q.add(new int[] {i,j});
                    vis[i][j] = true;
                }
            }
        }
        while (!q.isEmpty()){
            int sz = q.size();
            while(sz>0){
                int[] k = q.poll();
                sz--;
                for (int i = 0; i < 4; i++) {
                    int x = dx[i] +k[0];
                    int y = dy[i] +k[1];
                    if (x>=0 && x<m && y>=0 && y<n && grid.get(x).get(y)== 1 && vis[x][y]== false){
                        q.add(new int[] {x,y});
                        vis[x][y] = true;
                    }
                }
            }
            ret++;
        }
        for (int i = 0; i < m; i++) {
            for (int j = 0; j < n; j++) {
                if (grid.get(i).get(j) == 1 && vis[i][j] == false){
                    return -1;
                }
            }
        }
        return  ret-1;
    }



    //youyoudeyou
    public static PrintWriter out = new PrintWriter(new BufferedWriter(
            new OutputStreamWriter(System.out)));
    public static void main(String[] args) throws IOException{
        Read read = new Read();
        int a1 = read.nextInt();
        int[][] a = new int[a1][3];
        int[] dp = new int[a1];
        int[] count = new int[a1];
        for (int i = 0; i < a1; i++) {
            int min = Integer.MAX_VALUE;
            for (int j = 0; j < 3; j++) {
                a[i][j] = read.nextInt();
                min = Math.min(min,a[i][j]);
            }
            count[i] = a[i][1];
            dp[i] = min;
        }
        int sum = 0;
        for (int i = 0; i < a1; i++) {
            if (count[i]-dp[i]-1<=0){
                sum = dp[i]*2;
            }else{
                sum = dp[i]*2+(count[i]-dp[i]-1);
            }
            System.out.println(sum);
        }

    }



}